package com.fd;

import lombok.Data;

import java.util.Properties;

/**
 * 慢查询日志解析配置
 *
 * @author YangXiaoLong
 * @since 1.0.0
 */
@Data
public class SlowLogProperties {
    /**
     * 用户名
     */
    private String username;
    /**
     * 密码
     */
    private String password;

    /**
     * 数据库地址
     */
    private String url;

    /**
     * 日志文件
     */
    private String logPath;

    /**
     * 获取配置
     *
     * @param properties 加载配置
     * @return {@link SlowLogProperties}
     * @author YangXiaoLong
     * @since 1.0.0
     */
    public static SlowLogProperties getSlowLogProperties(Properties properties) {
        final String username = properties.getProperty("mysql.username");
        final String password = properties.getProperty("mysql.password");
        final String url = properties.getProperty("mysql.url");
        final String logPath = properties.getProperty("slow.log.path");

        SlowLogProperties logProperties = new SlowLogProperties();
        logProperties.setUsername(username);
        logProperties.setPassword(password);
        logProperties.setUrl(url);
        logProperties.setLogPath(logPath);
        return logProperties;
    }
}
